//
// Created by Semir on 2020/4/26.
//

#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;

struct Student {
    int score;
    int age;
    string name;
    Student() : score(0), age(0), name("") {}
    Student(int score, int age, string name) : score(score), age(age), name(name) {}

    friend bool operator < (const Student &a, const Student &b) {
        return a.score < b.score;
    }

//    friend bool operator < (const Student* &a, const Student* &b) {
//        return a->score < b->score;
//    }
};

struct cmp1 {
    bool operator() (const Student* a, const Student* b) {
        return a->score > b->score;
    }
};

struct cmp2 {
    bool operator() (const Student &a, const Student &b) {
        return a.score < b.score;
    }
};

//priority_queue<Student*> Q1;
//priority_queue<Student> Q2;
priority_queue<Student*, vector<Student*>, cmp1> Q3;
//priority_queue<Student, vector<Student>, cmp2> Q4;


//void test01() {
//    auto* s1 = new Student(94, 15, "张三");
//    auto* s2 = new Student(93, 15, "张四");
//    auto* s3 = new Student(97, 15, "张五");
//    auto* s4 = new Student(91, 15, "张六");
//    Q1.push(s1);
//    Q1.push(s2);
//    Q1.push(s3);
//    Q1.push(s4);
//    while (!Q1.empty()) {
//        cout << Q1.top()->name << Q1.top()->score << endl;
//        Q1.pop();
//    }
//}

//void test02() {
//    Student s1(94, 15, "张三");
//    Student s2(93, 15, "张四");
//    Student s3(97, 15, "张五");
//    Student s4(91, 15, "张六");
//    Q2.push(s1);
//    Q2.push(s2);
//    Q2.push(s3);
//    Q2.push(s4);
//    while (!Q2.empty()) {
//        cout << Q2.top().name << Q2.top().score << endl;
//        Q2.pop();
//    }
//}

void test03() {
    auto* s1 = new Student(94, 15, "张三");
    auto* s2 = new Student(93, 15, "张四");
    auto* s3 = new Student(97, 15, "张五");
    auto* s4 = new Student(91, 15, "张六");
    Q3.push(s1);
    Q3.push(s2);
    Q3.push(s3);
    Q3.push(s4);
    while (!Q3.empty()) {
        cout << Q3.top()->name << Q3.top()->score << endl;
        Q3.pop();
    }
}

//void test04() {
//    Student s1(94, 15, "张三");
//    Student s2(93, 15, "张四");
//    Student s3(97, 15, "张五");
//    Student s4(91, 15, "张六");
//    Q4.push(s1);
//    Q4.push(s2);
//    Q4.push(s3);
//    Q4.push(s4);
//    while (!Q4.empty()) {
//        cout << Q4.top().name << Q4.top().score << endl;
//        Q4.pop();
//    }
//}

int main() {
    test03();
    return 0;
}
